Repository navigation
Fix #1956: cap packages/codev vitest at 3 workers (singleFork was dead since Vitest 4) - #1965
Open
waleedkadous wants to merge 7 commits into
Open
waleedkadous wants to merge 7 commits into
waleedkadous wants to merge 7 commits into
Conversation
…as dead since Vitest 4 Vitest 4 removed test.poolOptions, so poolOptions.forks.singleFork was ignored and the unit suite ran availableParallelism() - 1 files at once (17 on an 18-core Mac). Replace it with the top-level maxWorkers option, from one shared constant in vitest-workers.ts, in all three packages/codev configs (unit, cli, e2e; the cli and e2e configs had no cap at all). 3 is vitest's default on GitHub's 4-vCPU runners, so CI parallelism is unchanged. VITEST_MAX_WORKERS overrides it for one run. Also corrects two comments that described the old behaviour: vitest-setup.ts's 'with singleFork all files share one process' and the e2e config's 'maxConcurrency: 1 // Run sequentially' (maxConcurrency only limits test.concurrent tests within one file).
…3-worker cap Resolves vitest.config.ts, vitest.cli.config.ts and vitest.e2e.config.ts through vitest/node's public resolveConfig and asserts maxWorkers is 3, so a future vitest that ignores or renames the option fails this test instead of silently restoring per-core parallelism. Fails on the pre-fix configs (maxWorkers undefined for all three).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
One run of the
packages/codevunit suite (porch'stestscheck) took an 18-core Mac from a one-minute load of about 8 to between 30 and 59. Under that load the suite's own process-spawning tests missed their 5-second timeouts. GitHub's runners passed the same code every time.Fixes #1956
Root cause
vitest.config.tsasked for one fork withpoolOptions.forks.singleFork: true. The installed vitest is 4.1.4, and Vitest 4 removedtest.poolOptions. All of this was checked in the installed package, not from memory:resolveConfigonly prints a deprecation forpoolOptions, and nothing invitest/distreadssingleFork.maxWorkers,resolveMaxWorkers()returnsos.availableParallelism() - 1in run mode. That is 17 files at once on the 18-core Mac and 3 on GitHub's 4-vCPU runners (ubuntu-latestandwindows-latest; the repo is public). Hence the Mac-only failures.maxForkstomaxWorkers,singleForktomaxWorkers: 1, isolate: false, andVITEST_MAX_FORKStoVITEST_MAX_WORKERS.vitest.cli.config.tsandvitest.e2e.config.ts, both spawn-heavy (the built binary, real Tower servers), had no cap at all.Reproduced without a full run: on the old config, 8 small test files ran in 8 forks at once, and
resolveConfiggavemaxWorkers: undefinedfor all three configs.Fix
packages/codev/vitest-workers.ts:MAX_WORKERS = 3, one shared constant used as the top-levelmaxWorkersin all threepackages/codevconfigs. It replaces the deadpoolOptionsblock invitest.config.ts.VITEST_MAX_WORKERSchanges the count for one run. vitest reads it itself, so this PR adds no code for it.isolatekeeps its default oftrue, so each file still gets a fresh fork, as it has under Vitest 4.vitest-setup.tssaid "withsingleForkall ~200 unit files share one process".maxConcurrency: 1 // Run sequentially.maxConcurrencyonly limitstest.concurrenttests within one file; it never stopped files running in parallel.apps/{streamdeck,vscode,web},packages/{core,sdk,artifact-canvas}. None has a deadpoolOptionsblock, and nopoolOptionsorsingleForkremains anywhere in the repo.Testing
Regression test:
src/__tests__/bugfix-1956-vitest-worker-cap.test.tsresolves each of the three configs throughvitest/node's publicresolveConfigand assertsmaxWorkers === 3. It checks the resolved config, not the file's keys: the original bug was a key that was present but ignored. It clearsVITEST_MAX_WORKERSwhile resolving. It fails 3/3 on the old configs (expected undefined to be 3) and passes 3/3 with the fix.Targeted runs: the deprecation line no longer prints. The 8-file probe peaks at 3 forks (was 8), and 1 with
VITEST_MAX_WORKERS=1. The issue's 10 spawn-heavy files run together and pass: 239 tests in 36 s, peak load 4.4.The one owner-approved full local run, made through porch's own checks (
porch done), 18-core Mac:Slowest files (vitest results cache):
spec-1280-measurement-instrument35 s,session-manager28 s,pir-1233-session-launch-loop22.5 s. The issue's 10 spawn-heavy files total 73 s in the full run against 89 s run alone at the cap, so their times are normal for them, not load-inflated.For the owner: the capped local run is green with the machine at a load of about 8. The standing rulings that let GitHub's green run stand in for porch's local
testscheck can be retired. That is the owner's call, not this PR's.Review notes (CMAP: codex REQUEST_CHANGES, claude APPROVE)
0ff39b3,ff2f0c2andb97dc59for starting withchore(porch):. Those are porch's own state commits, written by porch, andmaincarries 92 of them in its last 200 commits. Rewording them would mean rewriting pushed history. Not changed; codex found no code, test, scope or security issues.